package com.csdig.cms.common.springmvc;

import java.io.FileNotFoundException;

import javax.servlet.ServletContext;

import org.springframework.web.context.ServletContextAware;
import org.springframework.web.util.WebUtils;

import com.csdig.cms.common.RealPathResolver;
import com.csdig.cms.utils.OSUtils;

public class ServletContextRealPathResolver implements RealPathResolver, ServletContextAware {

	private ServletContext context;

	@Override
	public void setServletContext(ServletContext arg0) {
		this.context = arg0;
		init();
	}

	@Override
	public String get(String path) throws FileNotFoundException {
		return WebUtils.getRealPath(context, path);
	}

	private void init() {
		try {
			if (!OSUtils.isWindowOs()) {
				
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

}
